package cn.wen.mybatis.framework.plugin;import java.util.ArrayList;import java.util.Collections;import java.util.List;/** * Mybatis通过InterceptorChain进行了很好的扩展。 * 拦截链 */public class InterceptorChain {    //拦截器    private final List<Interceptor> interceptors = new ArrayList<>();    //动态代理拦截器    public Object pluginAll(Object target) {        for (Interceptor interceptor : interceptors) {            target = interceptor.plugin(target);        }        return target;    }    //添加拦截器    public void addInterceptor(Interceptor interceptor) {        interceptors.add(interceptor);    }    public List<Interceptor> getInterceptors() {        return Collections.unmodifiableList(interceptors);    }}